package org.easiermock;

import org.easiermock.testmocks.TestDelegate;
import org.easiermock.testmocks.RealInterface;
import org.junit.Assert;
import org.junit.Before;

public class EasierMockListenerTest extends AbstractEasierMockTest {
	
	private CountingMethodListener countingMethodListener;

	@Before
	public void setUp() {
		countingMethodListener = new CountingMethodListener();
	}
	
	@Override
	protected <T extends RealInterface> T createAbstractMock(
			Class<T> abstractDelegateClass) {
		return EasierMock.createMock(abstractDelegateClass, countingMethodListener);
	}

	@Override
	protected <T extends RealInterface> T createConcreteMock(
			Class<T> realClass, TestDelegate delegate) {
		return EasierMock.createMock(realClass, delegate, countingMethodListener);
	}

	@Override
	protected <T extends RealInterface> void testMockBehaviour(T mock,
			TestDelegate delegate) {
		mock.method1();
		Assert.assertEquals(1, countingMethodListener.getBeforeCount("method1"));
		mock.method1();
		Assert.assertEquals(2, countingMethodListener.getBeforeCount("method1"));
	}
	
}
